At present, a virtual machine can be migrated between interconnected data centers. However, after the virtual machine is migrated across data centers, location information of the virtual machine is changed. Therefore, all the interconnected data centers need to update an outbound interface of the virtual machine in a local media access control (MAC) routing table in order to synchronize the location information of the virtual machine such that all the data centers can accurately forward a data flow that accesses the virtual machine.
A method for synchronizing location information of a migrated virtual machine is as follows.
As shown in FIG. 1, after a first virtual machine (designated as VM) 112 is migrated from a second data center 120 to a first data center 110, the first virtual machine 112 broadcasts a gratuitous Address Resolution Protocol (ARP) packet in the first data center 110.
After receiving the gratuitous ARP packet, a first gateway 111 of the first data center 110 finds that the first gateway 111 has saved a MAC routing entry of the first virtual machine 112, and a MAC address and an Internet Protocol (IP) address of the first virtual machine 112 belong to the first data center 110. Therefore, the first gateway 111 updates an outbound interface in the MAC routing entry of the first virtual machine 112 to a local outbound interface, increases a saved serial number corresponding to the first virtual machine 112 by one, and sends a new serial number, that is increased by one, of the first virtual machine 112 to a gateway of another data center using a Border Gateway Protocol (BGP) message. In FIG. 1, the BGP message reaches a second gateway 121 of the second data center 120 and a third gateway 131 of a third data center 130.
After receiving the new serial number of the first virtual machine 112, the second gateway 121 and the third gateway 131 compare the new serial number of the first virtual machine 112 with a saved original serial number of the first virtual machine 112. If the new serial number is greater than the locally saved original serial number, the locally saved serial number of the first virtual machine 112 is updated to the received new serial number, and an outbound interface of the first virtual machine 112 in a local MAC routing table is updated to an outbound interface corresponding to the first data center 110 on a network side in order to update location information of the first virtual machine 112.
However, the foregoing manner has the following problems.
If the second data center 120 in which the first virtual machine 112 is located before migration recovers normal communication after the second gateway 121 is faulty, after fault rectification, the second gateway 121 republishes a MAC route of the first virtual machine 112 in the second data center 120 to a gateway of another data center using a BGP message. A serial number in the BGP message is obtained by increasing a saved serial number by one. However, actually the first virtual machine 112 is already migrated to the first data center 110 and completes registration. Therefore, the first gateway 111 also publishes the MAC route of the first virtual machine 112 in the first data center 110 using a BGP message. As described above, the serial number in the BGP message published by the first gateway 111 is also obtained by increasing, by one, a serial number generated according to the MAC address and the IP address. Because the serial numbers in the two BGP messages that are published by the first gateway 111 and the second gateway 121 are the same, when the third gateway 131 of the other data center receives the two BGP messages, the third gateway 131 cannot determine the data center in which the first virtual machine 112 currently is actually located, and may inaccurately update a location of the first virtual machine 112 to the second data center 120.
Therefore, in other approaches, location information of a virtual machine may be inaccurately updated to a data center in which the virtual machine is located before migration. In this case, when the data center in which the virtual machine is located before migration deletes old virtual machine information, long time interruption of traffic accessing the virtual machine is caused.